package com.dingding.service.rule.impl;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.dingding.common.core.beans.Rules;
import com.dingding.common.core.util.ToolUtil;
import com.dingding.facde.rule.service.IRuleService;
import com.dingding.service.rule.dao.IRulesDao;

@Component("ruleService")
public class RuleServiceImpl implements IRuleService {

	private Logger log = Logger.getLogger(this.getClass());

	@Resource(name = "rulesDao")
	private IRulesDao rulesDao; // 规则dao

	/**
	 * @Description:通过规则id获取规则详情
	 * @param ruleId 规则id
	 * @author fengshuonan
	 * @return Rules 规则详情
	 */
	@Transactional(readOnly = true)
	public Rules getRuleDetailById(String ruleId) {

		if (ToolUtil.isBlank(ruleId)) {
			return null;
		}

		Rules rule = null;

		try {
			rule = rulesDao.getById(ruleId);
		} catch (Exception e) {
			log.error("通过规则id获取规则详情异常！RuleServiceImpl : getRuleDetailById()", e);
		}

		return rule;
	}

}
